#!/bin/bash

## Copyright (c) 2013, PoiXson, Mattsoft
## <http://poixson.com/>
## <http://mattsoft.net/>
## 
## Permission to use, copy, modify, and/or distribute this software for any
## purpose with or without fee is hereby granted, provided that the above
## copyright notice and this permission notice appear in all copies.
## 
## THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
## WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
## ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
## ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
## OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.


if [ -z "$DEBUG" ]; then
	source $(dirname $0)/_common.sh
fi


title "Updating repo ${1} ..."
newline
echo "Mirrors base: ${PXN_REPOMIRRORS}"
echo -n "Updating: ${1} ."; sleepdot
cd "${PXN_REPOMIRRORS}/${1}.git/"
newline
newline


echo "updating from svn"
echo "================="
echo git svn rebase
git svn rebase
newline
newline


echo "pushing to github"
echo "================="
echo git push origin master
git push origin master
newline
newline


# echo Dumping repo..
# echo =================
# rsvndump $2 > $1.dump.temp
# rm $1.dump.2
# mv $1.dump $1.dump.2
# mv $1.dump.temp $1.dump
# echo


# echo chown
# echo =================
# chown user:user ./ -Rc
# echo


# mirror
# sh update-repo.sh GrowControl
# sh update-repo.sh WebAuctionPlus
#  sh update-repo.sh WebAuctionPlus-Sandbox
# sh update-repo.sh WeBookPlus
# sh update-repo.sh ProSiteManager
# sh update-repo.sh pxnCommon


# dump
# if [ "$1" == "dump" ]; then
#	# dump
#	sh dump-repo.sh GrowControl http://growcontrol.googlecode.com/svn/
#	sh dump-repo.sh WebAuctionPlus http://webauctionplus.googlecode.com/svn/
#	sh dump-repo.sh WeBookPlus http://webookplus.googlecode.com/svn/
#	sh dump-repo.sh ProSiteManager http://prositemanager.googlecode.com/svn/
# else
#	echo
#	echo
#	echo Skipping - Not dumping repos!
# fi


# echo chown/chmod
# chown user:user -c *.sh
# chown user:user -c _dumps/*.dump
# chmod 775 -c *.sh
# chmod 775 -c _dumps/*.dump
# echo

